package com.icinfo.cloud.provider.punish.ucase.investigateevidence.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.common.electricsent.dto.CaseTrialRecordQueryDto;
import com.icinfo.cloud.provider.punish.common.electricsent.dto.CaseTrialRecordSaveDto;
import com.icinfo.cloud.provider.punish.common.electricsent.vo.CaseTrialRecordDetailVo;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.service.ICaseTrialRecordService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import com.icinfo.framework.tools.utils.MapUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 *
 * 描述：案件审理记录（自然资源条线）
 *
 * @author shishengyao
 * @description
 * @date 2022/11/10
 */
@RestController
@RequestMapping("/punish/ucase/case/investigate/trial")
@Slf4j
public class CaseTrialRecordController extends BaseController {
    @Resource
    private ICaseTrialRecordService caseTrialRecordService;

    /**
     * 【】描述：获取案件审理记录详情（自然资源条线）
     *
     * @param queryDto 查询dto
     * @return {@link Result<CaseTrialRecordDetailVo> }
     * @author shishengyao
     * @date 2022/11/10
     */
    @RequestMapping("/getCaseTrialRecord")
    public Result<CaseTrialRecordDetailVo> getCaseTrialRecord(@RequestBody @Validated CaseTrialRecordQueryDto queryDto) {
        CaseTrialRecordDetailVo caseTrialRecord = caseTrialRecordService.getCaseTrialRecord(queryDto);
        return Result.success(caseTrialRecord);
    }

    /**
     * 【】描述：保存案件审理记录（自然资源条线）
     *
     * @param saveDto 保存dto
     * @return {@link Result<CaseTrialRecordDetailVo> }
     * @author shishengyao
     * @date 2022/11/10
     */
    @RequestMapping("/saveCaseTrialRecord")
    public Result<Map<String, Object> > saveCaseTrialRecord(@RequestBody @Validated CaseTrialRecordSaveDto saveDto) {
        Map<String, Object> resultMap = caseTrialRecordService.saveCaseTrialRecord(saveDto);
        String status = MapUtils.getString(resultMap, "success", "");
        if ("true".equals(status)) {
            return Result.success(Constant.STRING_SAVE_SUCCESS,resultMap);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }
}
